/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ucsur.tp.school.actions;

import edu.ucsur.tp.colegio.dao.factories.SchoolDaoFactory;
import edu.ucsur.tp.colegio.daos.ServicioSchoolDao;
import edu.ucsur.tp.school.forms.ServicioForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author Administrador
 */
public class ServicioAction extends DispatchAction {

    SchoolDaoFactory factory = SchoolDaoFactory.getInstance(SchoolDaoFactory.TEMP_DATA);
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";

    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction1, where "method" is the value
     * specified in <action> element : ( <action parameter="method" .../> )
     */
    public ActionForward guardar(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        ServicioSchoolDao servicioDao = factory.getServicioClienteBean();
        servicioDao.insertar(((ServicioForm)form).getServicio());
        return mapping.findForward(SUCCESS);
    }

    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction2, where "method" is the value
     * specified in <action> element : ( <action parameter="method" .../> )
     */
    public ActionForward myAction2(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        return mapping.findForward(SUCCESS);
    }
}